package com.alkin.thing.common;

import com.alkin.thing.project.system.domain.SysDictData;
import com.alkin.thing.project.system.service.ISysDictDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 字典工具类
 */
@Component
public class DictDataHelper {
    @Autowired
    private ISysDictDataService dictDataService;

    /**
     * 根据字典类型KEY获取值和Label映射
     * @param dictKey
     * @return
     */
    public Map<String, String> getDictValueLabelMap(String dictKey) {
        List<SysDictData> siteRoomTypeList = dictDataService.selectDictDataByType(dictKey);
        return siteRoomTypeList.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));
    }
}
